package com.yiren.dbaa.module.practice_set.basestation.presenter;

import android.app.Activity;

import com.yiren.dbaa.currency.api.CommonCallBack;
import com.yiren.dbaa.module.practice_set.basestation.bean.BaseStationBean;
import com.yiren.dbaa.module.practice_set.basestation.contract.BaseStationHomeContract;
import com.yiren.dbaa.module.practice_set.basestation.model.BaseStationHomeModel;
import com.yiren.dbaa.module.practice_set.map.contract.AddMapContract;
import com.yiren.dbaa.module.practice_set.map.model.AddMapModel;
import com.yiren.dbaa.view.dialog.LoadDialog;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lwb
 * @date : 2022/12/12 15:17
 * @description:  基站首页
 */
public class BaseStationHomePresenter implements BaseStationHomeContract.Presenter {
    private Activity activity;
    private BaseStationHomeContract.Model baseHomeModel;
    private AddMapContract.Model  addMapModel;

    public BaseStationHomePresenter(Activity activity) {
        this.activity = activity;
        baseHomeModel = new BaseStationHomeModel(activity);
        addMapModel = new AddMapModel(activity);
    }

    @Override
    public void loadBaseStationList(BaseStationHomeContract.View view) {
        LoadDialog.show(activity, "正在获取基站，请稍后...");
        addMapModel.getBaseStationList(new CommonCallBack() {
            @Override
            public void success(Object result) {
                LoadDialog.dismiss(activity);
                List<BaseStationBean> baseStationBeans = (List<BaseStationBean>) result;
                view.showBaseStationList(baseStationBeans);
            }

            @Override
            public void fail(String error) {
                LoadDialog.dismiss(activity);
                List<BaseStationBean> baseStationBeans = new ArrayList<>();
                 view.showBaseStationList(baseStationBeans);
            }
        });
    }
}
